package com.example.goods_service.controller;

import com.example.goods_service.return_data.Mall_Data;
import com.example.goods_service.service.GoodsServiceImpl_liujingxi;
import com.example.goods_service.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@Api
public class GoodsController_liujingxi {

    @Autowired
    GoodsServiceImpl_liujingxi goodsServiceImpl_liujingxi;
    Mall_Data mall_data = new Mall_Data();


    @ApiOperation("查询商品信息")
    @RequestMapping("/selectgoods")
    public Mall_Data selectgoods(@RequestParam("id")int id){
        List<T_commodity> list = goodsServiceImpl_liujingxi.selectgoods(id);
        System.out.println("goods"+list);
        return new Mall_Data(200,"正常！",list);
    }

    @ApiOperation("查询商品图片")
    @RequestMapping("/selectpicture")
    public Mall_Data selectpicture(@RequestParam("id")int id){
        List<T_picture> list = goodsServiceImpl_liujingxi.selectpicture(id);
        System.out.println("picture"+list);
        return new Mall_Data(200,"正常！",list);
    }

    @ApiOperation("查询商品规格详情")
    @RequestMapping("/selectattribute")
    public Mall_Data selectattribute(@RequestParam("id")int id){
        List<T_commodity_allocation> list = goodsServiceImpl_liujingxi.selectattribute(id);
        System.out.println("attribute"+list);
        return new Mall_Data(200,"正常！",list);
    }

    @ApiOperation("查询商品规格")
    @RequestMapping("/selectconfiguration_type")
    public Mall_Data selectconfiguration_type(@RequestParam("id")int id) {
        List<T_category_config> list = goodsServiceImpl_liujingxi.selectconfiguration_type(id);
            System.out.println("configuration_type="+ list);
        return new Mall_Data(200,"正常！",list);
    }

    @ApiOperation("查询一级类型")
    @RequestMapping("/selectcolor")
    public Mall_Data selectcolor(@RequestParam("color")String color,
                                 @RequestParam("id")int id) {
        List<T_config_details> list = goodsServiceImpl_liujingxi.selectcolor(color,id);
        System.out.println("color="+ list);
        return new Mall_Data(200,"正常！",list);
    }

    @ApiOperation("查询二级类型")
    @RequestMapping("/selecter")
    public Mall_Data selecter(@RequestParam("er")String er,
                              @RequestParam("id")int id) {
        List<T_config_details> list = goodsServiceImpl_liujingxi.selecter(er,id);
        System.out.println("er="+ list);
        return new Mall_Data(200,"正常！",list);
    }

    @ApiOperation("查询三级类型")
    @RequestMapping("/selectsan")
    public Mall_Data selectsan(@RequestParam("san")String san,
                               @RequestParam("id")int id) {
        List<T_config_details> list = goodsServiceImpl_liujingxi.selectsan(san,id);
        System.out.println("san="+ list);
        return new Mall_Data(200,"正常！",list);
    }

    @ApiOperation("查询四级类型")
    @RequestMapping("/selectsi")
    public Mall_Data selectsi(@RequestParam("si")String si,
                              @RequestParam("id")int id) {
        List<T_config_details> list = goodsServiceImpl_liujingxi.selectsi(si, id);
        System.out.println("si=" + list);
        return new Mall_Data(200, "正常！", list);
    }

    @ApiOperation("查询对应类型价格")
    @RequestMapping("/selectpirce")
    public Mall_Data selectprice(@RequestParam("id")int id,
                              @RequestParam("attribute")String attribute ) {
        List<T_commodity_allocation> list = goodsServiceImpl_liujingxi.selectpirce(id,attribute);
        System.out.println("price=" + list);
        return new Mall_Data(200, "正常！", list);
    }

    @ApiOperation("查询对应类型库存")
    @RequestMapping("/selectstock")
    public Mall_Data selectstock(@RequestParam("id")int id,
                                 @RequestParam("attribute")String attribute ) {
        List<T_commodity_allocation> list = goodsServiceImpl_liujingxi.selectstock(id,attribute);
        System.out.println("stock=" + list);
        return new Mall_Data(200, "正常！", list);
    }
}

